using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.Common;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace ForGVN
{
    public partial class Form3 : Form
    {
        public Form3()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            button1.Enabled = false;
            toolStripStatusLabel1.Text = "Loading data, please wait...";
            Application.DoEvents();
            DataTable dtb = null;

            if(radioButton2.Checked)
                dtb = Class2.RI_BY_A_DATE(dateTimePicker1.Value.ToShortDateString());
            else if(radioButton1.Checked)
                dtb = Class2.RI_BY_A_DATE_G(dateTimePicker1.Value.ToShortDateString());

            toolStripStatusLabel1.Text = "Ready...";
            button1.Enabled = true;
            if (dtb != null)
            {
                dataGridView1.DataSource = dtb;

                dataGridView1.SelectAll();
                dataGridView1.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText;
                Clipboard.SetDataObject(dataGridView1.GetClipboardContent());

                MessageBox.Show("Data has been copied to clipboard", "Notice", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("Error", "Notice", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }

        private void Form3_Load(object sender, EventArgs e)
        {
            radioButton1.Select();
        }
    }
}